package main

import (
	"github.com/spf13/viper"
	"github.com/tycme/gin-chat/router"
	"github.com/tycme/gin-chat/service"
	"github.com/tycme/gin-chat/util"
	"time"
)

func main() {
	e := router.Router()
	go service.Manager.Start()
	go service.StartUdp()
	InitTimer()
	//e.Run(":8081")

	e.Run(viper.GetString("server.port"))
	//viper.GetString("mongodb.url")
}

// 初始化定时器
func InitTimer() { //龚采华 ，下面map并发有问题
	util.Timer(time.Duration(viper.GetInt("timeout.DelayHeartbeat"))*time.Second, time.Duration(viper.GetInt("timeout.HeartbeatHz"))*time.Second, service.CleanConnection, "")
}
